#
# ${R_HOME}/src/library/grDevices/src/Makefile

pkg = grDevices

VPATH = @srcdir@
srcdir = @srcdir@
top_srcdir = @top_srcdir@

top_builddir = ../../../..
subdir = src/library/$(pkg)/src
R_HOME = $(top_builddir)
R_SHARE_DIR = $(R_HOME)/share
R_INCLUDE_DIR = $(R_HOME)/include

SOURCES_C = axis_scales.c chull.c devices.c init.c stubs.c colors.c \
  devCairo.c devPicTeX.c devPS.c \
  devQuartz.c @BUILD_AQUA_TRUE@ qdBitmap.c qdPDF.c
SOURCES_M = @BUILD_AQUA_TRUE@ qdCocoa.m

DEPENDS = $(SOURCES_C:.c=.d) $(SOURCES_M:.m=.d)
OBJECTS = $(SOURCES_C:.c=.o) $(SOURCES_M:.m=.o)

SHLIB = $(pkg)@SHLIB_EXT@

# need Defn.h etc, and config.h
PKG_CPPFLAGS =-I../../../include -I$(top_srcdir)/src/include -DHAVE_CONFIG_H

@BUILD_AQUA_TRUE@AQUA_LIBS = -framework AppKit
PKG_LIBS = $(AQUA_LIBS) -lz

all: Makedeps
	@$(MAKE) shlib @BUILD_DEVCAIRO_TRUE@ cairodevice

Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
	@cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@

Makedeps: Makefile $(DEPENDS)
	@cat $(DEPENDS) >> Makefile
	@touch $@

shlib: $(SHLIB)
	@$(MKINSTALLDIRS) \
	  $(top_builddir)/library/$(pkg)/libs@R_ARCH@
	@$(SHELL) $(top_srcdir)/tools/copy-if-change $(SHLIB) \
	  $(top_builddir)/library/$(pkg)/libs@R_ARCH@/$(SHLIB)

cairodevice:
	@(cd cairo && $(MAKE))

include $(R_HOME)/etc${R_ARCH}/Makeconf
include $(top_srcdir)/share/make/shlib.mk
LTO = @LTO@

mostlyclean: clean
clean:
	@-rm -Rf .libs _libs
	@-rm -f Makedeps *.d *.o *$(SHLIB_EXT)
	@(cd cairo && $(MAKE) clean)
distclean: clean
	@-rm -f Makefile
	@(cd cairo && $(MAKE) distclean)
maintainer-clean: distclean

## Automagically generated dependencies:
